An API-key restricted to the endpoint-scope
rbac.subjects:sync cannot use any business API, here
GET /api/hs/office/memberships as an example. Even though
the global ADMIN role is granted to its API_KEY subject, which would
allow viewing all memberships, the endpoint is out of scope and responds
with 403 Forbidden.
| name | value |
|---|---|
| subjectUuid | a91c0008-0000-0000-0000-000000000008 |
| subjectName | business.attempt.key |
An API-key can be restricted to named endpoint-scopes, here
rbac.subjects:sync, which only allows
GET /api/rbac/subjects,
GET /api/rbac/subjects/{uuid}, and
PUT /api/rbac/subjects/{uuid} (create-or-update,
incl. declarative deactivation via deactivated: true —
deliberately no DELETE). The scopes are an additional fence
on top of the roles granted to the API_KEY subject: even with the global
ADMIN role, e.g. granted to sync ALL subjects as needed for a Keycloak
subject synchronization, all endpoints outside the scopes respond with
403 Forbidden. An API-key without scopes remains
unrestricted.
The scopes property restricts the API-key to the given
named endpoint-scopes. The response contains the generated clear-text
API-key (property apiKey) exactly once; it cannot be
retrieved again.
HTTP POST "/api/rbac/subjects" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }` \
<<EOF
{
"uuid" : "a91c0008-0000-0000-0000-000000000008",
"name" : "business.attempt.key",
"type" : "API_KEY",
"scopes" : [ "rbac.subjects:sync" ]
}
EOF
=> status: 201 CREATED a91c0008-0000-0000-0000-000000000008
{
"uuid" : "a91c0008-0000-0000-0000-000000000008",
"name" : "business.attempt.key",
"organization" : "business",
"type" : "API_KEY",
"apiKey" : "hsak_business.attempt.key.8704e2aea9cac53fa7a49ff64e34c5ee6f2357a3b96409470574195a4d0cedf9",
"scopes" : [ "rbac.subjects:sync" ],
"expiresAt" : null
}
The grant API needs the UUID of the role which we want to grant.
HTTP GET "/api/rbac/roles?name=rbac.global%23global%3AADMIN" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }`
=> status: 200 OK
[ {
"uuid" : "16e992d4-bed6-4678-9c76-8ee498fb13db", // globalAdminRoleUuidToGrant
"object.uuid" : "d906a1a8-bf20-4c1e-8251-8101f1d69af2",
"objectTable" : "rbac.global",
"objectIdName" : "global",
"roleType" : "ADMIN",
"roleName" : "rbac.global#d906a1a8-bf20-4c1e-8251-8101f1d69af2:ADMIN",
"roleIdName" : "rbac.global#global:ADMIN"
} ]
HTTP POST "/api/rbac/grants" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }` \
-H 'Hostsharing-Assumed-Roles: rbac.global#global:ADMIN' \
<<EOF
{
"assumed" : true,
"grantedRole.uuid" : "16e992d4-bed6-4678-9c76-8ee498fb13db", // globalAdminRoleUuidToGrant
"granteeSubject.uuid" : "a91c0008-0000-0000-0000-000000000008"
}
EOF
=> status: 201 CREATED 16e992d4-bed6-4678-9c76-8ee498fb13db // globalAdminRoleUuidToGrant
HTTP GET "/api/rbac/subjects" \
-H "Hostsharing-Api-Key: $HSADMINNG_API_KEY"
=> status: 200 OK
[
{
"uuid" : "242a0005-0000-0000-0000-000000000005",
"name" : "abc-peter.smith",
"organization" : "abc",
"type" : "USER"
},
{
"uuid" : "93043ec0-3d42-4f3f-817c-7213d8c9ed6a",
"name" : "/abc-Team",
"organization" : "abc",
"type" : "GROUP"
},
{
"uuid" : "a91c0005-0000-0000-0000-000000000005", // ApiKey-Subject: bootstrapped.key
"name" : "bootstrapped.key",
"organization" : "bootstrapped",
"type" : "API_KEY"
},
{
"uuid" : "a91c0008-0000-0000-0000-000000000008",
"name" : "business.attempt.key",
"organization" : "business",
"type" : "API_KEY"
},
{
"uuid" : "242a0006-0000-0000-0000-000000000006",
"name" : "def-peter.smith",
"organization" : "def",
"type" : "USER"
},
"..."
]
HTTP GET "/api/rbac/subjects/a91c0008-0000-0000-0000-000000000008" \
-H "Hostsharing-Api-Key: $HSADMINNG_API_KEY"
=> status: 200 OK
{
"uuid" : "a91c0008-0000-0000-0000-000000000008",
"name" : "business.attempt.key",
"organization" : "business",
"type" : "API_KEY"
}
HTTP GET "/api/hs/office/memberships" \
-H "Hostsharing-Api-Key: $HSADMINNG_API_KEY"
=> status: 403 FORBIDDEN
{
"path" : "/api/hs/office/memberships",
"statusCode" : 403,
"statusPhrase" : "Forbidden",
"message" : "ERROR: [403] API-key scopes do not allow GET /api/hs/office/memberships"
}
generated on 2026-08-10 04:42:40 for branch HEAD